﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OLMS.DAL;
using OLMS.BLL;

namespace OLMS
{
    public partial class ChangePassword : System.Web.UI.Page
    {       
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Users user = Session["user"] as Users;
                if (user != null)
                {
                    lblUserName.Text = "用户姓名：" + user.UserName;
                }
                else
                {
                    Response.Redirect("Login.aspx");
                }
                               
            }
        }

        protected void btnChange_Click(object sender, EventArgs e)
        {
            Users user = Session["user"] as Users;
            if (UserBLL.ChangePassword(user.UserId, txtOldPwd.Text, txtNewPwd.Text))
            {
                Response.Redirect("Login.aspx");
            }
            else
            {
                Response.Write("<script>alert('密码更改错误!')</script>");
            }
        }

        protected void btnReturn_Click(object sender, EventArgs e)
        {
            Response.Redirect("Index.aspx");
        }
    }
}